<?php
    require 'phpincludes/fbconfig.php';
    require 'phplibs/rss_php.php';
    
    $fbfeedurl = 'http://www.facebook.com/feeds/page.php?id='.$fbpageid.'&format=rss20';

    $rss = new rss_php();
    $rss->load($fbfeedurl);
    
    $fbfeed = $rss->getItems();

    if(count($fbfeed) > 0){
        foreach($fbfeed as $item){
            $pluspos = strpos($item['pubDate'], '+');
            $itemdisplaydate = substr($item['pubDate'], 0, $pluspos - 1);
            
            echo '<div class="fbfeeditem">'
                    .'<div class="fbfeeditempic">'
                        .'<a href="'.$fbpageurl.'" target="_BLANK" />'
                            .'<img src="'.$fbpagepicurl.'" alt="'.$fbpagename.'" />'
                        .'</a>'
                    .'</div>'
                    .'<div class="fbfeeditemtexts">'
                        .'<div class="fbfeeditemname">'
                            .'<a href="'.$fbpageurl.'" target="_BLANK" />'
                                .$fbpagename
                            .'</a>'
                        .'</div>'
                        .'<div class="fbfeeditemdescription">'.$item['description'].'</div>'
                        .'<div class="fbfeeditemdate">'.$itemdisplaydate.'</div>'
                    .'</div>'
                  .'</div>';
        }
    }
    else{
        echo 'Could not connect to Facebook';
    }
?>